﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ShoppingWebSite
{
    public partial class ggxx : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (txtNewpassword.Text == txtConnewpassword.Text)
            {
                SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=ShoppingDB;Integrated Security=True");
                cn.Open();
                SqlCommand cmd = new SqlCommand("select * from UserName where UName='" + Session["username"].ToString() + "'", cn);
                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                DataSet dt = new DataSet();
                    ad.Fill(dt);
                cn.Close();
                dt.Tables[0].Rows[0]["UPwd"] = txtNewpassword.Text.Trim();
                SqlCommandBuilder builder = new SqlCommandBuilder(ad);

                ad.Update(dt);
                lblInfo.Text = "密码修改成功";
            }
            else
            {
                lblInfo.Text = "两次密码不一致，请重新输入！";
            }

        }
    }
}